// import * as api from "./api";

import React from "react";
import { RouteObject } from "react-router-dom";
// import { Dayjs } from "dayjs";

// api 中使用
export interface CommonI {
  id?: string; //
  createdAt?: string;
  createdBy?: string;
  updatedAt?: string;
  updatedBy?: string;
  deletedAt?: string;
  deletedBy?: string;
}

export interface ResponseDataI<T> {
  status: number;
  message?: string;
  data: T;
  code: string;
}

export interface SearchParamsI {
  searchText: string;
  searchedColumn: string;
  currentPage: number;
  pageSize: number;
  sortField: string;
  sortOrder: string;
}

export type BreadItem = {
  // href: string;
  // title: string;
  label: string;
  key: string;
  icon?: any;
};

// 系统设置
export type SettingsI = {
  collapsedMenu: boolean;
  allowUpload: boolean;
  network: string;
  breadcrumbs: BreadItem[];
};

// 类型与接口(interface)在扩展联合类型的能力上有所不同 (我正在回答我自己的问题)这是因为您不能使用接口(interface)扩展联合类型。您必须使用类型别名
export type RoutePropsType = RouteObject & {
  meta?: {
    auth?: boolean;
    roles?: string[];
    unRoles?: string[];
    name?: string;
    icon?: React.ReactNode;
    key?: string;
    isMenu: boolean;
    component?: any;
    // layout?: typeof AntdLayout;
  };
  children?: RoutePropsType[];
};

// 微信公众号授权返回的用户信息
export interface WeixinOauthI {
  id?: string;
  oauthType: string;
  openid: string;
  nickname: string;
  sex: number;
  province: string;
  city: string;
  country: string;
  headimgurl: string;
  privileges: string;
  unionid: string;
  deleteFlag: boolean;
  sign: string;
  userID: string;
}

export interface TenantI extends CommonI {
  name: string;
}

export interface ResourceI {
  name: string;
  methods: string;
  domain?: string;
  subject?: string;
  summary: string;
  description: string;
}

export interface RoleI extends CommonI {
  name: string;
  py?: string;
  pinyin?: string;
  isActive: boolean;
  tenantId: string;
  tenant: TenantI;
  resources: ResourceI[];
}

export interface RoleUserI {
  id?: string;
  roleId: string;
  role?: RoleI;
  userId?: string;
}

// 系统用户信息
export interface UserI extends CommonI {
  accessToken: string;
  refreshToken: string;
  username: string;
  cellphone: string;
  email: string;
  nickname: string;
  lastName: string;
  firstName: string;
  fullName: string;
  empCode?: string;
  birthday: Date | null; // store中的对象如果使用Dayjs类型会引发：rror: A state mutation was detected between dispatches, in the path 'user.birthday.parse'.报错
  password: string;
  sex: number;
  score: number;
  avatarURL: string;
  lastLoginAt: Date | null;
  isActive: boolean;
  isSuperuser: boolean;
  roleUsers: RoleUserI[];
  roles?: string[]; // 用于保存用户角色id，传给roleUsers;
  currentRole?: RoleI;
  // tenantID: string;
  // tenant: TenantI;
  resources: ResourceI[];
  depts: string;
  // policies: string[][];
}

export interface PatientI extends CommonI {
  name: string;
  pinYinCode: string;
  pyCode: string;
  UID: string;
  sex: number;
  dateOfBirth: string;
  age?: number;
  contactName1: string;
  relationshipWithPatient1: string;
  cellphone1: string;
  contactName2: string;
  relationshipWithPatient2: string;
  cellphone2: string;
  contactName3: string;
  relationshipWithPatient3: string;
  cellphone3: string;
  wardName: string;
  address: string;
  comment: string;
}

export interface RootStateI {
  settings: SettingsI;
  weixinOauth: WeixinOauthI;
  user: UserI;
}

export interface IndividualI extends CommonI {
  code: string;
  name: string;
  cellphone: string;
  email: string;
  fullName: string;
  birthday: string;
  sex: number;
  isActive: boolean;
  comment: string;
  category: string;
  experience: number;
}

export interface EmployeeI extends CommonI {
  code: string;
  name: string;
  py: string;
  pinyin: string;
  department: string;
  title?: string;
  sex?: number;
  dateOfBirth?: string;
  age?: number;
  QCPNo?: string;
  comment?: string;
  cellphone?: string;
  cellphone1?: string;
  address?: string;
  users?: UserI[];
  tenantVerifiedTime?: string;
}

export interface HospitalI extends CommonI {
  name: string;
  pinYinCode: string;
  pYCode: string;
  provinceName: string;
  address: string;
  zipcode: string;
  phoneNumber: string;
  director: string;
  numberOfBed: number;
  PPD: number;
  grade: string;
  depts: string;
}

export interface UploadedFileI extends CommonI {
  filename: string;
  filepath: string;
  fileType: string;
  fileSize: number;
  md5: string;
  fileUrl?: string;
  magicType: string;
  bucket?: string;
  key?: string;
  fileURL?: string;
  uploader?: UserI;
  individual?: IndividualI;
}

export interface JsApiTicketI {
  id: string;
  platform: string;
  appID: string;
  errcode: number;
  errmsg: string;
  ticket: string;
  expiresIn: number;
}

export interface ChatMessageI extends CommonI {
  role: "user" | "bot";
  content: string;
}

export interface SessionMessageI extends CommonI {
  title: string;
  archived: boolean;
  messages: ChatMessageI[];
}

export interface ChatCompletionRequestI {
  model: string;
  messages: Partial<ChatMessageI>[];
  functions?: any;
  temperature?: number;
  top_p?: number;
  max_length?: number;
  stream?: boolean;
  stop?: string[];
}

export interface ChatCompletionResponseChoiceI {
  index: number;
  message: ChatMessageI;
  finish_reason: "stop" | "length" | "function_call";
}

export interface DeltaMessageI {
  role?: Array<"user" | "assistant" | "system">;
  content?: string;
}

export interface ChatCompletionResponseStreamChoiceI {
  index: number;
  delta: DeltaMessageI;
  finish_reason?: Array<"stop" | "length">;
}

export interface ChatCompletionResponseI {
  model: string;
  object: "chat.completion" | "chat.completion.chunk";
  // choices: ChatCompletionResponseChoiceI[] | ChatCompletionResponseStreamChoiceI[];
  choices: ChatCompletionResponseChoiceI[];
  created?: number;
}
